<?php
namespace app\company\validate;


class SupplierValidate extends BaseValidate
{
    public function __construct()
    {
        $rule = [
            "name"                  => 'require|max:50',
            'abbreviation'          => 'require|max:10',
            "real_name"             => 'require|max:10',
            "user_name"             => 'require|unique:supplier_user',
            "mobile"                => 'require|max:11',
            "province_id"           => 'require|integer',
            "city_id"               => 'require|integer',
            "area_id"               => 'require|integer',
            "address"               => 'require|max:50',
            'type'                  => 'require|in:1,2,3,4,5'
        ];

        $message = [
            "name.require"                  => '第三方名称不能为空',
            "name.max"                      => '第三方名称长度不能超过50个字符',
            "abbreviation.require"          => '第三方简称不能为空',
            "abbreviation.max"              => '第三方简称长度不能超过10个字符',
            "real_name.require"             => '负责人姓名不能为空',
            "real_name.max"                 => '负责人姓名长度不能超过10个字符',
            "user_name.require"             => '第三方用户名不能为空',
            "user_name.unique"              => '第三方用户名已存在',
            "mobile.require"                => '负责人手机号不能为空',
            "mobile.max"                    => '负责人手机号长度不能超过11个字符',
            "province_id.require"           => '省Id不能为空',
            "province_id.integer"           => '省Id必须为整数',
            "city_id.require"               => '市Id不能为空',
            "city_id.integer"               => '市Id必须为整数',
            "area_id.require"               => '区Id不能为空',
            "area_id.integer"               => '区Id必须为整数',
            "address.require"               => '第三方地址不能为空',
            "address.max"                   => '第三方地址长度不能超过50个字符',
            'type.require'                  => '第三方类型不能为空',
            'type.in'                        => '第三方类型不正确'
        ];

        $scene = [
            'add'  => ['name','real_name', 'mobile', 'province_id', 'city_id', 'area_id', 'address','type','user_name'],
        ];
        parent::__construct($rule, $message, $scene);
    }
}